/* eslint-disable */
// 该文件由 OneAPI 自动生成，请勿手动修改！
import {apiPrefixDispose} from '@/utils/format';
import {request} from '@umijs/max';


/**
 * 查询用户信息接口
 */
export async function userInfoApi<T = any>() {
  return request<API.ResultVO<API.UserVO>>(apiPrefixDispose('/user/info'), {
    method: 'GET',
    // headers: {
    //   [process.env.TOKEN_NAME]: localStorage.getItem(process.env.TOKEN_LOCAL_STORAGE_NAME) || ''
    // },
  });
}


/**
 * 查询用户信息接口
 */
export async function userPage<T = any>(body: API.UserPage) {
  return request<API.ResultPageVO<API.UserVO>>(apiPrefixDispose('/user/page'), {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
  });
}


/**
 * 管理员注册用户
 */
export async function adminRegister<T = any>(body: API.UserAdd) {
  return request<API.ResultVO<string>>(apiPrefixDispose('/register/system'), {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
  });
}



/**
 * 删除用户
 */
export async function deleteById<T = any>(
  id: number,
  options?: { [key: string]: any },
) {
  return request<API.ResultVO<string>>(apiPrefixDispose('/user/delete'), {
    method: 'GET',
    params: {'id':id},
    ...(options || {}),
  });
}



/**
 * 分配角色
 */
export async function assignRole<T = any>(body: API.RoleUserSetting) {
  return request<API.ResultVO<string>>(apiPrefixDispose('/user/assign/roles'), {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
  });
}

/**
 * 取消用户的角色
 */
export async function cancelRole<T = any>(body: API.RoleUserSetting) {
  return request<API.ResultVO<string>>(apiPrefixDispose('/user/cancel/roles'), {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
  });
}



/**
 * 查询用户拥有的角色
 */
export async function findUserRoles<T = any>(params: {userId: number|string}) {
  return request<API.ResultVO<API.RoleVO[]>>(apiPrefixDispose('/user/roles'), {
    method: 'GET',
    params: { ...params }
  });
}

